package com.myfoon.view.context.helper;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class FormValidator {
    
    public static final String emailRegex = "^[_A-Za-z0-9-]+(\\.[_A-Za-z0-9-]+)*@[A-Za-z0-9-]+(\\.[A-Za-z0-9-]+)*(\\.[_A-Za-z0-9-]+)";
    public static final String nameRegex = "[A-Za-z][\\sA-Za-z]{0,20}";
    
    public FormValidator() {
    }

    public static boolean isValidEmail(String email) {        
        return isValid(emailRegex, email);
    }
    
    public static boolean isValidName(String name) {
        return true;
        //return isValid(nameRegex, name);
    }
    
    public static boolean isValid(String regex, String value) {
        Pattern p = Pattern.compile(regex);
        Matcher m = p.matcher(value);

        boolean matchFound = m.matches();
        return matchFound;
    }
}
